<?php
class Db{
	private $link;

	public function __construct()
	{
		$this->connect();
	}

	//数据库连接
	private function connect()
	{
		$dsn = "mysql:host=localhost;dbname=c50";
		$username="root";
		$password = "admin888";
		try{
			$this->link = new Pdo($dsn,$username,$password);
		}catch(PDOException $e) {
			die($e->getMessage());
		}
		$this->link->query("set names utf8");
	}

	//发送查询
	public function query($sql)
	{
		$result = $this->link->query($sql);
		return $result->fetchAll(PDO::FETCH_ASSOC);
	}
}